package com.xlkj.ms.tools.core.response;

import com.xlkj.ms.tools.core.model.Data;

import java.util.List;

/**
 * 分页响应报文格式：
 * <pre>
 * {@code
 *     {
 *         "code":"***",
 *         "msg":"****",
 *         "data":{
 *             "count":***,
 *             "lists":[{***},{***}]
 *         }
 *     }
 * }
 * </pre>
 * @author zhuqifeng
 * @date 2021/11/10 13:55
 * @package com.xlkj.ms.tools.core.response
 */
public abstract class AbstractPageDataResponse<E> extends AbstractResponse {

    private static final long serialVersionUID = 9215462286846161702L;

    private DataCounts<E> data;

    public AbstractPageDataResponse() {}

    public AbstractPageDataResponse(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public AbstractPageDataResponse(String code, String msg, DataCounts<E> data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public AbstractPageDataResponse(DataCounts<E> data) {
        this.data = data;
    }

    public DataCounts<E> getData() {
        return data;
    }

    public void setData(DataCounts<E> data) {
        this.data = data;
    }

    public static class DataCounts<E> extends Data {

        private static final long serialVersionUID = 583818072978280878L;

        private long count;

        private List<E> lists;

        public DataCounts() {}

        public DataCounts(long count, List<E> lists) {
            this.count = count;
            this.lists = lists;
        }

        public long getCount() {
            return count;
        }

        public void setCount(long count) {
            this.count = count;
        }

        public List<E> getLists() {
            return lists;
        }

        public void setLists(List<E> lists) {
            this.lists = lists;
        }

    }
}